const app = getApp();

Component({
  data: {
    theme: app.globalData.theme,
    selected: 0,
    color: "#f8f0df",
    selectedColor: "#fff",
    background: "",
    list: [
      {
        pagePath: "/pages/index/index",
        text: "首页",
        iconPath: "/static/icon/tabbar/love.png",
        selectedIconPath: "/static/icon/tabbar/love-o.png",
        number: "",
      },
      {
        pagePath: "/pages/message/message",
        text: "动态",
        iconPath: "/static/icon/tabbar/msg.png",
        selectedIconPath: "/static/icon/tabbar/msg-o.png",
        number: "",
      },
      {
        pagePath: "/pages/story/story",
        text: "时光机",
        iconPath: "/static/icon/tabbar/story.png",
        selectedIconPath: "/static/icon/tabbar/story-o.png",
        number: "",
      },

      {
        pagePath: "/pages/user/user",
        text: "我的",
        iconPath: "/static/icon/tabbar/user.png",
        selectedIconPath: "/static/icon/tabbar/user-o.png",
        number: "",
      },
    ],
  },

  methods: {
    // 切换 tab 事件
    switchTab(e) {
      //   this.watchBack();
      //   this.getTabBar().watchBack();
      const data = e.currentTarget.dataset;
      const url = data.path;

      // 跳转页面
      wx.switchTab({ url });
      this.setData({
        selected: data.index,
      });
    },

    watchBack() {
      //   console.log(wx.getStorageSync("theme"));
      this.setData({
        theme: app.globalData.theme,
        // theme: wx.getStorageSync("theme") || app.globalData.theme,
      });
    },
  },
});
